using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class InvoicespaymentMap : EntityTypeConfiguration<Invoicespayment>
    {
        public InvoicespaymentMap()
        {
            // Primary Key
            this.HasKey(t => t.id);

            // Properties
            this.Property(t => t.Invno)
                .HasMaxLength(8);

            this.Property(t => t.party)
                .HasMaxLength(5);

            this.Property(t => t.Invcurrency)
                .HasMaxLength(5);

            // Table & Column Mappings
            this.ToTable("Invoicespayment");
            this.Property(t => t.id).HasColumnName("id");
            this.Property(t => t.PaymentNb).HasColumnName("PaymentNb");
            this.Property(t => t.Invno).HasColumnName("Invno");
            this.Property(t => t.party).HasColumnName("party");
            this.Property(t => t.amount).HasColumnName("amount");
            this.Property(t => t.closed).HasColumnName("closed");
            this.Property(t => t.BalanceBeforepayment).HasColumnName("BalanceBeforepayment");
            this.Property(t => t.Balanceafterpayment).HasColumnName("Balanceafterpayment");
            this.Property(t => t.Invcurrency).HasColumnName("Invcurrency");

            // Relationships
            this.HasOptional(t => t.PSPayment)
                .WithMany(t => t.Invoicespayments)
                .HasForeignKey(d => d.PaymentNb);

        }
    }
}
